<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
    <title>心理咨询预约系统</title>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="__USER__/js/layui/layui.js"></script>
    <link rel="stylesheet" href="__USER__/js/layui/css/layui.css">
    <link rel="stylesheet" href="__USER__/css/base.css">
    <link rel="stylesheet" href="__USER__/css/page/head.css">
    <link rel="stylesheet" href="__USER__/css/page/foot.css">
    <link rel="stylesheet" href="__USER__/css/page/index.css">
</head>
<body>
<div class="head-box">
    <div class="head-tit layui-row">
        <div class="headTit-inner layui-col-md-offset2 layui-col-md8">
            <div class="fl headTit-left">
                <div class="logo fl" style="margin-left: -40%">
                    <img src="__USER__/img/logo.png">
                </div>
                <div class="tit-txt fl" style="margin-left: -25%">
                    <div class="head-tit-bg"><a href="index.html">预约咨询服务平台</a></div>
                    <div class="head-tit-sm">预约诊疗服务平台</div>
                </div>
            </div>
            <div class="fr headTit-right layui-row" style="width: 500px">
                <ul>
                    <li class="layui-nav-item" style="margin-left:99%;margin-top:2%;width: 700px">
                        <a href="../expert/info.html"><span style="font-size: 14px; color: #010101">欢迎,   </span><span
                                style="font-size: 20px; color: #0f6bed">   {$Request.session.expertname}   </span> </a>
                        <a style="text-decoration: none" href="javascript:void(0);" onclick="message()"><i
                                class="layui-icon layui-icon-notice"
                                title="消息"><span style="font-size: 14px; color: #2BC807">({$xcount})</span></i></a>

                        <a href="../expert/logout"> <span style="font-size: 14px; color: #010101">    ,   退出</span></a>
                    </li>
                </ul>
                <div class="layui-row">

                </div>
            </div>
        </div>
    </div>

    <div class="head-tab layui-row">
        <div class="headTab-inner layui-col-md-offset2 layui-col-md8">
            <ul class="headTab-ul" style="margin-left: 17%">
                <li>
                    <a href="info.html">个人中心</a>
                </li>
                <li>
                    <a href="myorder.html">我的预约</a>
                </li>
                <li>
                    <a href="message.html">查看留言</a>
                </li>
            </ul>
        </div>
    </div>
</div>

<hr class="hr20">
<div style="margin-left: 150px;width: 1px;height: 500px; background: black;"></div>
<div style="margin-left: 70px;margin-top:-450px;font-size: 20px"><a
        href="myorder.html"><span style="color: rgba(55,148,222,0.68)">进行中</span></a>
</div>
<div style="margin-left: 70px;margin-top:350px;font-size: 20px"><a href="complete.html">
    <span style="color: rgba(55,148,222,0.68)">已完成</span></a>
</div>


<div class="layui-form" style="font-size: 15px">
    <p style="font-family: 楷体;font-size: 25px;margin-left: 42%;margin-top: -450px">当前有（<span
            style="color: rgba(15,112,255,0.68)">{$count}</span>）条 <b>进行中</b> 的预约</p>

    <div style="margin-left: 15%">
        <div class="layui-inline">
            <table id="test" lay-filter="test" lay-data="{id: 'test'}"
                   style="border:1px solid black;margin: 0 auto;"></table>
        </div>
    </div>

</div>

<div class="layui-row">
    <div>
        <div class="cardTit">
            <!-- <span class="cardTit-tit">友情链接</span> -->
        </div>
        <div class="body-card">
            <div id="linkurl" class="link-box">
            </div>
        </div>
    </div>

    <div class="layui-col-md12 foot-about">
        <div class="about-box">
            <div><a href="aboutUs.html">关于我们</a></div>
            <span>|</span>
            <div><a href="yinsi.html">隐私条款</a></div>
            <span>|</span>
            <div><a href="contactUs.html">联系我们</a></div>
            <div class="clear"></div>
        </div>
        <div>Copyright © 2019 - 2025 WEDOCTOR. All Rights Reserved. 苏孙举 版权所有</div>
    </div>
</div>


<!--    编辑弹出层-->
<script type="text/html" id="edit_form">
    <div class="layui-row">
        <div class="layui-form">
            <div class="text"
                 style="width: 1000px;height: 100%;margin: auto;padding-top: 20px;font-size: 14px;font-family: Consolas">
                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        预约号</label>
                    <div class="layui-input-inline">
                        <input type="text" id="id" name="id" disabled="disabled" required lay-verify="required"
                               autocomplete="off"
                               class="layui-input"></div>
                    <div class="layui-form-mid layui-word-aux">
                        预约唯一标识
                    </div>
                </div>


                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        学生姓名</label>
                    <div class="layui-input-inline">
                        <input type="text" id="sname" name="sname" disabled="disabled" required lay-verify="required"
                               autocomplete="off"
                               class="layui-input"></div>
                </div>


                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        学生学号</label>
                    <div class="layui-input-inline">
                        <input type="text" id="sid" name="sid" disabled="disabled" required lay-verify="required"
                               autocomplete="off"
                               class="layui-input"></div>
                </div>

                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        学生年龄</label>
                    <div class="layui-input-inline">
                        <input type="text" id="age" name="age" disabled="disabled" required
                               lay-verify="required|agecheck"
                               autocomplete="off"
                               class="layui-input"></div>
                </div>

                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        学生性别</label>
                    <div class="layui-input-inline">
                        <select id="sex" name="sex" lay-verify="required" disabled="disabled" autocomplete="off"
                                class="layui-input">
                            <option value=""></option>
                            {volist name="sexlist" id="vo"}
                            <option value="{$vo.sex}">{$vo.sex}</option>
                            {/volist}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        学院</label>
                    <div class="layui-input-inline">
                        <select id="depart" name="depart" lay-verify="required" disabled="disabled" autocomplete="off"
                                class="layui-input">
                            <option value=""></option>
                            {volist name="departlist" id="vo"}
                            <option value="{$vo.depart}">{$vo.depart}</option>
                            {/volist}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        年级</label>
                    <div class="layui-input-inline">
                        <select id="slevel" name="slevel" lay-verify="required" disabled="disabled" autocomplete="off"
                                class="layui-input">
                            <option value=""></option>
                            {volist name="slevellist" id="vo"}
                            <option value="{$vo.slevel}">{$vo.slevel}</option>
                            {/volist}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        民族</label>
                    <div class="layui-input-inline">
                        <input type="text" id="nation" name="nation" disabled="disabled" required=""
                               lay-verify="required"
                               autocomplete="off" class="layui-input"></div>
                </div>


                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        手机</label>
                    <div class="layui-input-inline">
                        <input type="text" id="phone" name="phone" disabled="disabled" required
                               lay-verify="required|phone"
                               autocomplete="off"
                               class="layui-input"></div>
                </div>


                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        预约时间</label>
                    <div class="layui-input-inline">
                        <input type=type="text" id="time" name="time" required autocomplete="off"
                               class="layui-input"></div>
                    <div class="layui-form-mid layui-word-aux">
                    </div>
                </div>


                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        预约地址</label>
                    <div class="layui-input-inline">
                        <select id="address" name="address" lay-verify="required" autocomplete="off"
                                class="layui-input">
                            <option value=""></option>
                            {volist name="roomnumlist" id="vo"}
                            <option value="{$vo.roomnum}">{$vo.roomnum}</option>
                            {/volist}
                        </select>
                    </div>
                </div>

                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        教师姓名</label>
                    <div class="layui-input-inline">
                        <select id="ename" name="ename" lay-verify="required" disabled="disabled" autocomplete="off"
                                class="layui-input">
                            <option value=""></option>
                            {volist name="enamelist" id="vo"}
                            <option value="{$vo.name}">{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>

                <hr class="hr10">
                <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                    <label class="layui-form-label">
                        问题描述</label>
                    <div class="layui-input-inline">
                <textarea rows="10" cols="30" class="tarea" id="problem" disabled="disabled" name="problem" required
                          lay-verify="required"
                          autocomplete="off" style="width: 640px; height: 100px;margin: 0;"></textarea>
                    </div>
                    <hr class="hr10">
                    <div class="layui-form-item" style="width: 45%;float: left;clear: none;margin-bottom: 30px;">
                        <label class="layui-form-label"></label>
                        <button class="layui-btn" lay-filter="update" id="update" lay-submit="update">保存修改</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</script>

<!--//操作栏-->
<script type="text/html" id="barDemo">
    <a style=" text-decoration: none"><i class="layui-icon layui-icon-edit toolbars" lay-event="edit" title="查看"></i>
    </a>
    <a style=" text-decoration: none"><i class="layui-icon layui-icon-delete" lay-event="del" title="取消"></i> </a>
</script>

<script>


    layui.use(['form', 'layer', 'jquery', 'table'], function () {
        var table = layui.table;
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        //修改监听
        form.on('submit(update)', function (data) {
            var id = $('#id').val();
            var address = $('#address').val();
            var time = $('#time').val();
            var sname = $('#sname').val();

            // console.log(id);
            // console.log(address);
            // console.log(time);

            $.ajax({
                type: "post",
                url: "{:url('Expert/orderupdate')}",
                dataType: "json",
                data: {
                    "id": id, "address": address, "time": time, "sname": sname
                },
                async: false,//必须是同步提交的
                success: function (data) {
                    // console.log(data);
                    if (data.data == 1) {
                        layer.msg("修改成功！", {icon: 1, time: 1000}, function () {
                            setTimeout('window.location.reload()', 100);
                        });
                    } else {
                        layer.msg("修改失败！", {icon: 2, time: 1000}, function () {
                            setTimeout('window.location.reload()', 100);
                        });
                    }
                },
            });
        });
    });


    layui.use(['form', 'layer', 'jquery', 'table'], function () {
        var table = layui.table;
        $ = layui.jquery;
        var form = layui.form,
            layer = layui.layer;

        var flag = 0;

        $(document).ready(function () {
            //消息检测
            if (flag == 0) {
                $.ajax({
                    type: "get",
                    url: "{:url('Expert/checkmessage')}",
                    async: false,
                    success: function (data) {
                        //   console.log(data);
                        if (data != 0) {
                            layer.msg("您有（" + data + "）条新信息，请注意查看！");
                            flag = 1;
                        }
                    }
                });
            }

            //预约状态检测
            $.ajax({
                type: "get",
                url: "{:url('Student/operastatus')}",
                async: false,
                success: function (data) {
                    //console.log(data);
                    // if (data.data = 0) {
                    //     count = 0;
                    // }
                }
            });
        });
    });

    //消息显示
    function message() {
        layer.open({
            type: 2,
            title: '',
            shadeClose: true,
            shade: 0.7,
            area: ['809px', '500px'],
            content: ['notify'],
            end: function () {
                $.ajax({
                    type: "get",
                    url: "{:url('Expert/changenotify')}",
                    async: false,
                    success: function (data) {
                        console.log(data);
                        //考虑读完之后数字为0
                    }
                });
            }
        });
    }

    layui.use('table', function () {
        var table = layui.table;
        table.render({
            // even: false //开启隔行背景
            // , size: 'sm' //小尺寸的表格
            // , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            minheight: "500px"
            , elem: '#test'
            , page: true
            , id: 'searchreload'
            , limit: 5
            , height: 450
            , width: 1200
            , url: "{:url('Expert/orderjson')}"
            , parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": 0, //解析接口状态
                    "msg": "刷新页面试试", //解析提示文本
                    "count": res.total, //解析数据长度
                    "data": res.data//解析数据列表
                };

            },
            cols: [[
                {field: 'id', title: '预约编号', width: 163}
                , {field: 'sname', title: '学生姓名', width: 200}
                , {field: 'time', title: '预约时间', width: 260, sort: true}
                , {field: 'address', title: '预约地点', width: 220}
                , {field: 'ename', title: '教师姓名', width: 200}
                // , {field: 'time', title: '预约时间', width: 80, sort: true}
                , {fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150}
            ]],

        });


        //监听行工具事件
        table.on('tool(test)', function (obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('真的要取消吗', function (index) {
                    layer.close(index);
                    $.ajax({
                        type: "post",
                        url: "{:url('Expert/cancel')}",
                        dataType: "json",
                        data: {"id": data.id, "sname": data.sname, "time": data.time},
                        async: false,
                        success: function (data) {
                            console.log(data);
                            if (data == 1) {
                                layer.msg("取消成功！", {icon: 1, time: 1000}, function () {
                                    setTimeout('window.location.reload()', 100);
                                });
                            } else if (data == 2) {
                                layer.msg("取消失败！", {icon: 2, time: 1000}, function () {
                                    setTimeout('window.location.reload()', 100);
                                });
                            }
                        }
                    });
                });
            } else if (obj.event === 'edit') {
                var id = data.id;
                layui.use('layer', function () {
                    var layer = layui.layer;
                    layer.open({
                        type: 1,
                        title: "预约详情",
                        shade: false,
                        area: ['1000px', '620px'],
                        content: $('#edit_form').html(),
                        success: function (layero, index) {
                            uneditid = id;
                            $.ajax({
                                type: "post",
                                url: "{:url('Student/geteditorder')}",
                                dataType: "json",
                                data: {"id": data.id},
                                async: false,
                                success: function (data) {
                                    //选择时间控件
                                    layui.use(['laydate'], function () {
                                        var laydate = layui.laydate;
                                        laydate.render({     //创建时间选择框
                                            elem: '#time' //指定元素
                                            , type: 'datetime', //日期格式
                                        });
                                    });
                                    table.reload('searchreload');
                                    $(" input[name='id']").val(data.list4.id);
                                    $(" input[name='sname']").val(data.list4.sname);
                                    $(" input[name='sid']").val(data.list4.sid);
                                    $(" input[name='time']").val(data.list4.time);

                                    var selectsexval;
                                    var selectdepartval;
                                    var selectslevelval;
                                    var selectenameval;
                                    var selecteroomnumval;
                                    var selectsex = document.getElementById("sex");
                                    var selectdepart = document.getElementById("depart");
                                    var selectslevel = document.getElementById("slevel");
                                    var selectename = document.getElementById("ename");
                                    var selectroomnum = document.getElementById("address");

                                    for (var i = 0; i < selectsex.options.length; i++) {
                                        if (selectsex.options[i].value == data.list4.sex) {
                                            selectsexval = selectsex.options[i].value;
                                            selectsex.options[i].selected = true;
                                            $("input[name='sex']").val(selectsex.options[i].value);
                                        }
                                    }
                                    for (var i = 0; i < selectdepart.options.length; i++) {
                                        if (selectdepart.options[i].value == data.list4.depart) {
                                            selectdepartval = selectdepart.options[i].value;
                                            selectdepart.options[i].selected = true;
                                            $("input[name='depart']").val(selectdepart.options[i].value);
                                        }
                                    }
                                    for (var i = 0; i < selectslevel.options.length; i++) {
                                        if (selectslevel.options[i].value == data.list4.slevel) {
                                            selectslevelval = selectslevel.options[i].value;
                                            selectslevel.options[i].selected = true;
                                            $("input[name='slevel']").val(selectslevel.options[i].value);
                                        }
                                    }

                                    for (var i = 0; i < selectename.options.length; i++) {
                                        if (selectename.options[i].value == data.list4.ename) {
                                            selectenameval = selectename.options[i].value;
                                            selectename.options[i].selected = true;
                                            $("input[name='ename']").val(selectename.options[i].value);
                                        }
                                    }

                                    for (var i = 0; i < selectroomnum.options.length; i++) {
                                        if (selectroomnum.options[i].value == data.list4.address) {
                                            selecteroomnumval = selectroomnum.options[i].value;
                                            selectroomnum.options[i].selected = true;
                                            $("input[name='address']").val(selectroomnum.options[i].value);
                                        }
                                    }

                                    //下拉框必须先赋值在 选中 再渲染
                                    $(layero).find('select[name=sex]').val(selectsexval);
                                    $(layero).find('select[name=depart]').val(selectdepartval);
                                    $(layero).find('select[name=slevel]').val(selectslevelval);
                                    $(layero).find('select[name=ename]').val(selectenameval);
                                    $(layero).find('select[name=address]').val(selecteroomnumval);

                                    $(" input[name='age']").val(data.list4.age);
                                    $(" input[name='phone']").val(data.list4.phone);
                                    $(" input[name='nation']").val(data.list4.nation);
                                    $(" textarea[name='problem']").val(data.list4.problem);

                                }
                            });
                            layui.form.render('select');
                        }
                    });
                })
            }
        })
    });
</script>
</body>
</html>